//display error on page
function error(msg) {
	$('.primary-details').prepend(
		$('<div class="errormsg">').html(msg)
	);
	return msg;
}





$(function() {
	//load base data and mods
	loadDom3Data(initGrids);
});

//create grids
function initGrids() {
	
	//toggle ids
	$('.dom3id-toggle').click(function() {
			if ($(this).is(':checked')) {
				//set id-toggle buttons on other pages
				$('.dom3id-toggle').attr('checked','checked');
				//add style
				$( "<style>.dom3id { display:table-row; }</style>" ).appendTo( "head" );
				
				//add column to table
				var columns = itemgrid.grid.getColumns();
				columns.unshift({ id: "id",     width: 40, name: "id", field: "id", sortable: true });
				itemgrid.grid.setColumns(columns);
			}
			else {
				$('.dom3id-toggle').removeAttr('checked');
				$( "<style>.dom3id { display:none; }</style>" ).appendTo( "head" );
				
				var columns = itemgrid.grid.getColumns();
				if (columns[0].id == 'id') {
					columns.shift();
					itemgrid.grid.setColumns(columns);
				}
			}
	});
	

	//display list of loaded mods
	if (modctx.loadedmods.length)
		$('.list-mods').html(modctx.loadedmods.join(',<br /> '));
	else 
		$('.list-mods').html('No mods loaded');
	


	//var itemgrid = new D3MIGrid('#item-page', item_page_grid_settings);
	var itemgrid = new ItemGrid('#item-page');	
}

